package edu.mobbuzz.web.pages;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.Retain;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

import edu.mobbuzz.daf.bean.Rss;
import edu.mobbuzz.daf.dao.IRssDao;
import edu.mobbuzz.web.base.SecureBasePage;

public class RssGridPage extends SecureBasePage{
	@Inject
	private IRssDao rssDao;
	
	private List<Rss> rssList;
	@Property
	private Rss rss;
	
	@Retain
	private BeanModel rssModel;
	@Inject
	private BeanModelSource beanModelSource;
	@Inject
	private ComponentResources resources;
	
	public IRssDao getRssDao() {
		return rssDao;
	}
	
	public BeanModel getRssModel() {
		return rssModel;
	}	
	
	public List<Rss> getRssList() {
		if(rssList==null){
			rssList = new ArrayList<Rss>();
		}
		rssList = getRssDao().queryForList("", "");		
		return rssList;
	}

	public void setRssList(List<Rss> rssList) {
		this.rssList = rssList;
	}

	void pageLoaded(){
		rssModel = beanModelSource.createDisplayModel(Rss.class, resources.getMessages());
	
	}
}
